<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>登录</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="__ADMIN__/layuiadmin/layui/css/layui.css" media="all">
    <style>
        html{
            width: 100%;
            height: 100%;
        }
        #wapper{
            min-width: 200px;
            max-width: 500px;
        }
    </style>
</head>

<body style="position: relative; width: 100%; height: 100%; background-size: 100% 100%; background-repeat: no-repeat; background-color: #1E9FFF;">

<div class="layui-container" style="position: relative; width: 100%; height: 100%;">
    <div class="layui-row" id="wapper" style="position: relative; z-index: 2; transform: translateY(50%); margin: 0 auto;">
        <div class="layui-col-md8 layui-col-md-offset2">
            <div class="layui-card">
                <div class="layui-card-header" style="text-align: center; font-weight: bold; font-size: 20px;">管理员登录</div>
                <div class="layui-card-body">
                    <form class="layui-form">
                        <div class="layui-form-item">
                            <input type="text" name="username" required lay-verify="required" placeholder="请输入用户名"
                                   autocomplete="off" class="layui-input">
                        </div>
                        <div class="layui-form-item">
                            <input type="password" name="password" required lay-verify="required" placeholder="请输入密码"
                                   autocomplete="off" class="layui-input">
                        </div>
                        <div class="layui-form-item">
                            <button class="layui-btn" lay-submit lay-filter="login" style="width: 100%;">登录</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="__ADMIN__/layuiadmin/layui/layui.js"></script>
<script>
    layui.use(['form'], function () {
        var $ = layui.$
            , form = layui.form
        //监听提交
        form.on('submit(login)', function (data) {
            //获取表单数据
            var username = data.field.username;
            var password = data.field.password;

            $.ajax({
                url: "{:url('login/check')}",
                data: {username: username, password: password}, //表单数据
                type: "Post",
                dataType: "json",
                success: function (data) {
                    console.log(data);
                    if (data.status) {
                        location.href = '/admin'

                        // layer.msg(data.msg);
                        // // location.reload(); //删除成功后再刷新
                        // layer.close(index); //关闭弹层
                        // table.reload('LAY-user-manage'); //数据刷新
                    } else {
                        layer.msg(data.msg);
                    }
                    //
                    // // location.reload(); //删除成功后再刷新
                    // // layer.close(index); //关闭弹层
                },
                error: function (data) {
                    console.log(data);
                    // $.messager.alert('错误', data.msg);
                }
            });

            // console.log(data);
            return false;
            // return true;
        });
    });
</script>

</body>
</html>
